-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: VHDS: on-demand updates #6552
Conversation
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
@htuch: the internal redirect is here: https://github.com/envoyproxy/envoy/pull/6552/files#diff-be24bc0fe90bba5c4e871fb56928e085R48 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, will focus on OnDemandUpdate
for until we have the base patches merged.
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
…d docs Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
@htuch: I think this is ready to be reviewed. Please let me know if you would like me to squash the commits (I think they'll need to be cleaned up, as the sequence of commits with respect to the base VHDS commit is out of order). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall structure/approach looks good, a few comments, would be great to cleanup various commented code and to generally add more docs/comments. Thanks!
@@ -150,6 +150,8 @@ class StreamFilterCallbacks { | |||
*/ | |||
virtual Router::RouteConstSharedPtr route() PURE; | |||
|
|||
virtual bool requestRouteConfigUpdate(std::function<void()> cb) PURE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add Doxygen docs for this?
@@ -79,6 +80,10 @@ class Subscription { | |||
* be passed to std::set_difference, which must be given sorted collections. | |||
*/ | |||
virtual void updateResources(const std::set<std::string>& update_to_these_names) PURE; | |||
|
|||
virtual void updateResourcesViaAliases(const std::set<std::string>&) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add Doxygen docs for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am perceiving the intention correctly, I think you might also want to change the name. updateResources()
is kind of misnamed; it's not about getting updated resources, but rather updating the set of resource names we care about. Similarly, it looks like this one is about adding to a list of aliases, not updating resources.
...so I guess I'm really saying now would be a good time to give updateResources()
a better name. Can I suggest something like either updateResourceInterest
or updateSubscriptionInterest
?
As for the aliases one, since it looks like it's more of a blanket addition than a "replace with this set" (which is how updateResources
currently works), I would suggest like addAliases
or addResourceAliases
.
@@ -48,6 +48,17 @@ class RouteConfigProvider { | |||
* Callback used to notify RouteConfigProvider about configuration changes. | |||
*/ | |||
virtual void onConfigUpdate() PURE; | |||
|
|||
/** | |||
* Callback used to request an update to the route configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An update from the management server?
* must match on | ||
* @param cb callback to be called when the configuration update has been propagated to worker | ||
* threads | ||
* @return whether a request for a configuration update has been successfully scheduled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How/why can this fail?
|
||
/** | ||
* Callback used to request an update to the route configuration. | ||
* @param for_domain supplies the domain name that virtual hosts contained in the VHDS response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit confusing, as it is an update request, but the thing we're requesting is referencing the response..
@@ -48,6 +48,11 @@ VhdsSubscription::VhdsSubscription(RouteConfigUpdatePtr& config_update_info, | |||
factory_context.api()); | |||
} | |||
|
|||
void VhdsSubscription::ondemandUpdate(const std::set<std::string>& aliases) { | |||
std::cout << "11111111111111111111111111111111111\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
} | ||
|
||
attempting_internal_redirect_with_complete_stream_ = false; | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
return false; | ||
} | ||
factory_context_.dispatcher().post( | ||
[this, for_domain]() -> void { subscription_->ondemandUpdate({for_domain}); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be onDemandUpdate
..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an issue of collision with Envoy callback naming, though, right? onDemandUpdate
sounds like a function that handles a "demand update". Not sure that there's a good solution here, hahaha....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe updateOnDemand
? lazyUpdate
?
tls_->runOnAllThreads([this, new_config]() -> void { | ||
tls_->getTyped<ThreadLocalConfig>().config_ = new_config; | ||
auto callbacks = config_update_callbacks_->getTyped<ThreadLocalCallbacks>().callbacks_; | ||
if (!callbacks.empty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a while
? What if there are multiple updates requested before a response is received? Do you have tests for this?
|
||
if (!callbacks_->decodingBuffer() && // Redirects with body not yet supported. | ||
callbacks_->recreateStream()) { | ||
// cluster_->stats().upstream_internal_redirect_succeeded_total_.inc(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this fits in with both the current subscription state stuff, and my ongoing work, very nicely; basically zero friction. That's a relief! I also like where the refactoring in DeltaSubscriptionState is going.
@@ -79,6 +80,10 @@ class Subscription { | |||
* be passed to std::set_difference, which must be given sorted collections. | |||
*/ | |||
virtual void updateResources(const std::set<std::string>& update_to_these_names) PURE; | |||
|
|||
virtual void updateResourcesViaAliases(const std::set<std::string>&) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am perceiving the intention correctly, I think you might also want to change the name. updateResources()
is kind of misnamed; it's not about getting updated resources, but rather updating the set of resource names we care about. Similarly, it looks like this one is about adding to a list of aliases, not updating resources.
...so I guess I'm really saying now would be a good time to give updateResources()
a better name. Can I suggest something like either updateResourceInterest
or updateSubscriptionInterest
?
As for the aliases one, since it looks like it's more of a blanket addition than a "replace with this set" (which is how updateResources
currently works), I would suggest like addAliases
or addResourceAliases
.
} | ||
|
||
void DeltaSubscriptionState::populateDiscoveryRequest( | ||
envoy::api::v2::DeltaDiscoveryRequest& request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may be able to factor out the if (!any_request_sent_yet_in_current_stream_)
block from populateDiscoveryRequest into its own function. Then, rather than having ifs+elses in getNextRequest(), you could just do
if (!any_request_sent_yet_in_current_stream_)
prepareFirstRequest(request);
if (!aliases_added_.empty())
populateWithAliases(request);
populateDiscoveryRequest(request);
@@ -76,10 +76,15 @@ void DeltaSubscriptionState::updateResourceInterest( | |||
} | |||
} | |||
|
|||
void DeltaSubscriptionState::updateResourceInterestViaAliases( | |||
const std::set<std::string>& updates_to_these_aliases) { | |||
aliases_added_.insert(updates_to_these_aliases.begin(), updates_to_these_aliases.end()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One surface-level (since I don't know how it's supposed to work) question to double check you're doing what you intend: is it your intention that aliases are only ever added, not removed? Or, it looks like the actual mechanism is that these aliases just go into resource_names_subscribe; does that mean that to remove them, you are supposed to just do a normal unsubscribe of those names?
return false; | ||
} | ||
factory_context_.dispatcher().post( | ||
[this, for_domain]() -> void { subscription_->ondemandUpdate({for_domain}); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an issue of collision with Envoy callback naming, though, right? onDemandUpdate
sounds like a function that handles a "demand update". Not sure that there's a good solution here, hahaha....
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
For an explanation of how to fill out the fields, please see the relevant section
in PULL_REQUESTS.md
Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
[Optional Fixes #Issue]
[Optional Deprecated:]